﻿options nolabel;

proc import out=work.test1 datafile="I:/prepare/pseudo_data.dta" dbms=dta replace;run; 

/*
symbol_id year month date 
ab_turn_daily_new_30 (DISAGREE)
ab_turn_daily_new_7 ab_turn_daily_new_15 ab_turn_daily_new_45  (Variations of DISAGREE for Table A1)
ab_vol_daily_new_7  ab_vol_daily_new_15 ab_vol_daily_new_30 ab_vol_daily_new_45 (Variations of DISAGREE for Table A1)
ret_daily holding_ret_daily holding_ret_daily_new three_factor_alpha_lead	CAPM_alpha_lead (return variables)  
cv_turn reversal abs_reversal mcap_last_month mcap mom_1_11 illiq IVOL ab_svi_median max_daily	(crypto characteristics, mcap is the log of mcap_last_month)  
cv_turn_lag reversal_lag abs_reversal_lag mom_1_11_lag illiq_lag IVOL_lag ab_svi_median_lag max_daily_lag (lag crypto characteristics)
OIBTRD OIBVOL DBVOL DSVOL DBTRD DSTRD	(trading activities variables)
OIBTRD_lag OIBVOL_lag DBVOL_lead DSVOL_lead DBTRD_lead DSTRD_lead (lag/lead trading activities variables) 
s_constraint	  (=1 if constrained, =0 if unconstrained)
constraint_type (=0.5 if movers)
*/ 

data test2; set test1; if year=2019 or (year=2018 and month>=8) or year=2020 or  year=2021;
quarter=qtr(date);
run;

proc sort data=test2; by date; run;
proc means data=test2 n mean std p25 p50 p75  noprint;
by date;
var mcap_last_month  /*or other firm characteristics in Table 1*/;
output out=test3 n=time_n mean=time_mean std=time_std p25=time_p25 p50=time_p50 p75=time_p75;
run;

proc means data=test3 mean;
var time_mean time_std time_p25 time_p50 time_p75;
run;

proc sql;
create table test4 as
select year, quarter, count(distinct symbol_id) as n, avg(mcap_last_month) as mcap_mean, median(mcap_last_month) as mcap_median
from test2
group by year, quarter;
quit;
